Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid stdin read by tailwindcss watch command #349

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

tompng
Copy link
Contributor

@tompng tompng commented Apr 24, 2024

Description

tailwindcss -w reads stdin, probably to detect stdin close.
When using binding.irb or debugger with tailwindcss-rails, some keystrokes are taken by tailwindcss and IRB/Debug can't read from stdin correctly. Keystroke disappears, and sometimes hangs up.
To not let tailwindcss watch command read stdin, we should use IO.popen(command, 'r+') instead of system(*command).
Workaround for #346

Reproduction code

watch_command = ['./node_modules/.bin/tailwindcss', '-w']
Thread.new do # same for `fork do`
  system(*watch_command)
  # IO.popen(watch_command, 'r+') do |io|
  #   IO.copy_stream(io, $stdout)
  # end
  puts 'command finished'
end
sleep 1
binding.irb

Side effect

Before this pull request, Ctrl-D will stop rails s. Closing stdin will stop tailwind, then puma will stop with a message Detected tailwind has gone away, stopping Puma...
After this change, Ctrl-D won't stop tailwind.

…ch command

`tailwindcss -w` reads stdin, probably to detect stdin close.
When using binding.irb or debugger with tailwindcss-rails, some keystrokes are taken by tailwindcss.
To not let tailwindcss watch command read stdin, we should use `IO.popen(command, 'r+')` instead of `system(*command)`.
Workaround for rails#346
@mbhnyc
Copy link

mbhnyc commented Apr 24, 2024

just hit this yesterday, applause!

@flavorjones
Copy link
Member

@tompng Thank you for opening this! Will try it out.

@flavorjones flavorjones merged commit cfaa58f into rails:main Apr 25, 2024
23 checks passed
@flavorjones
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants